<template>
  <view class="container">
    <scroll-view class="scroll-v" scroll-y="true">
      <view>
        <view class="uni-list-cell">
          <view class="uni-media-list">
            <view class="row">
              <view class="header col1">申请机构</view>
              <view class="header col2">申请基金</view>
              <view class="header col3 header3">操作</view>
            </view>
          </view>
        </view>
      </view>
      <view v-for="(item, index) in approveList" :key="index">
        <view
          class="uni-list-cell records"
          hover-class="uni-list-cell-hover"
          @click="goApproveDetail(item)"
        >
          <view class="uni-media-list">
            <view class="row">
              <view class="col1">
                <view>
                  <view class="line1">
                    <text class="companyName">{{ item.companyName }}</text>
                  </view>
                  <view class="line2">
                    <view>
                      {{ item.userName }}
                    </view>
                    <span class="span">|</span>
                    <text>{{ item.dateTime }}</text>
                  </view>
                </view>
              </view>
              <view class="col2">
                <view class="fundName">{{ item.fundName }}</view>
              </view>
              <view class="col3">
                <div class="file icon-fujian" @click.stop="showFiles(item)">
                  <uniTooltip
                    ><view slot="content">点击查看合格投资者证明材料</view>
                  </uniTooltip>
                </div>
                <div class="file icon-chuli" @click.stop="gotoDeal(item)">
                  <uniTooltip
                    ><view slot="content">点击审批通过或拒绝</view>
                  </uniTooltip>
                </div>
              </view>
            </view>
          </view>
        </view>
      </view>
    </scroll-view>
  </view>
  <uni-popup ref="popupDeal" :is-mask-click="true">
    <view class="popupContent">
      <view>
        <view class="message">
          <text
            >[一个超级神奇的机构啊啊啊啊]申请查看[巨巨巨能赔钱的产品]的净值</text
          >
        </view>
        <view class="reason">
          <textarea
            class="input"
            placeholder-class="placeholder"
            auto-height
            maxlength="50"
            placeholder="如果拒绝请输入原因"
            v-model="reason"
          />
        </view>
        <videw class="buttonPanel">
          <view>
            <button class="button" type="default" size="mini" @click="reject">
              拒绝
            </button>
            <button class="button" type="primary" size="mini" @click="accept">
              接受
            </button>
          </view>
        </videw>
      </view>
    </view>
  </uni-popup>
</template>

<script>
import { getApproveList } from "@/apis/api";
import uniTooltip from "@/uni_modules/uni-tooltip/components/uni-tooltip/uni-tooltip.vue";

export default {
  components: {
    uniTooltip,
  },
  data() {
    return {
      approveList: [],
      dealItem: "",
      message: "",
      reason: "",
    };
  },
  onLoad() {
    this.getDatas();
  },
  onShow: function () {
    wx.hideHomeButton();
  },
  methods: {
    getDatas() {
      getApproveList()
        .then((res) => {
          var newItems = [];
          //   "companyId": "@integer(60, 100)",
          //   "companyName": "@cword(4,8)",
          //   "userId": "@integer(60, 100)",
          //   "userName": "@cword(4,8)",
          //   "fundId": "@integer(60, 100)",
          //   "fundName": "@cword(4,8)",
          //   "fileList": ""
          res.data.data.forEach((e) => {
            newItems.push({
              ...e,
              hasFile: e.fileList.length > 0 ? true : false,
            });
          });
          this.approveList = newItems;
        })
        .catch((err) => {
          console.log("err", err);
        })
        .finally(() => {});
    },
    showFiles(e) {
      console.log("showFiles");
    },
    gotoDeal(e) {
      this.dealItem = e;
      this.message = `[${e.companyName}]申请查看[${e.fundName}]的净值`;

      this.$refs.popupDeal.open("center");
    },
    reject() {
      console.log("reject" + this.dealItem.companyName);
      this.$refs.popupDeal.close();
    },
    accept() {
      console.log("accept" + this.dealItem.companyName);
      this.$refs.popupDeal.close();
    },
    cancelDeal() {
      this.$refs.popupDeal.close();
    },
    goApproveDetail(e) {},
  },
};
</script>

<style lang="scss">
@import "apply.scss";
</style>
